package com.coder520.sync_learning.demo;

import java.util.concurrent.TimeUnit;

public class SynchronizedDefect {
    public synchronized void syncMethod(){
        try {
            TimeUnit.HOURS.sleep(1);

        }catch (Exception e){
            e.printStackTrace();
        }
    }
    
    public static void main(String[] args) throws InterruptedException {
        SynchronizedDefect defect=new SynchronizedDefect();
        Thread t=new Thread(defect::syncMethod,"t1");

        t.start();

        TimeUnit.MILLISECONDS.sleep(2);


        Thread t2=new Thread(defect::syncMethod,"t2");
        t2.start();
    }
}
